home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST7-13.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  806b  |  32 lines

  1. ;
  2. ; *** Listing 7-13 ***
  3. ;
  4. ; Adds up the elements of a byte-sized array using
  5. ; base-only addressing inside the loop, and using
  6. ; a memory operand with ADC.
  7. ;
  8.     jmp    Skip
  9. ;
  10. ARRAY_LENGTH    equ    1000
  11. TestArray    db    ARRAY_LENGTH dup (1)
  12. TEST_START_OFFSET equ    200    ;we'll add elements 200-299
  13. TEST_LENGTH    equ    100    ; of TestArray
  14. MemZero        db    0    ;the constant value 0
  15. ;
  16. Skip:
  17.     call    ZTimerOn
  18.     mov    bx,offset TestArray+TEST_START_OFFSET
  19.                 ;build the array start
  20.                 ; offset right into the
  21.                 ; base so we can use
  22.                 ; base+index addressing,
  23.                 ; with no displacement
  24.     sub    ax,ax        ;initialize sum
  25.     mov    cx,TEST_LENGTH    ;# of bytes to add
  26. SumArrayLoop:
  27.     add    al,[bx]        ;add in the next byte
  28.     adc    ah,[MemZero]    ; to the 16-bit sum
  29.     inc    bx        ;point to next byte 
  30.     loop    SumArrayLoop
  31.     call    ZTimerOff
  32.